//
//  MyCollectCell.swift
//  maosheng
//
//  Created by lxl on 2019/8/12.
//

import UIKit

class MyCollectNoImgCell: UITableViewCell {
    let titleLab = UILabel()
    let deleteBtn = UIButton(type: .custom)
    let mainView = UIView()

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)

        configCell()
        contentView.backgroundColor = KYP_f2f2f2_COLOR

    }
    
    
    func configCell() -> Void {
        mainView.backgroundColor = .white
        contentView.addSubview(mainView)
        mainView.snp.makeConstraints { (make) in
            make.left.right.top.equalTo(0)
            make.bottom.equalTo(-5)
        }
        
        mainView.addSubview(titleLab)
        titleLab.textAlignment = .left
        titleLab.numberOfLines = 0
        titleLab.lineBreakMode = .byWordWrapping
        titleLab.textColor = KYP_333333_COLOR
        titleLab.font = UIFont(name: PF_Medium, size: 15)
        titleLab.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.top.equalTo(23)
            make.right.equalTo(-15)
        }
        
       
        
        addTheImageView()
        let imgView = mainView.viewWithTag(201)

        deleteBtn.setTitleColor(KYP_999999_COLOR, for: .normal)
        deleteBtn.setTitle("删除收藏", for: .normal)
        deleteBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
        mainView.addSubview(deleteBtn)
        deleteBtn.snp.makeConstraints { (make) in
            make.bottom.equalTo(-5)
            make.right.equalTo(-15)
            if imgView != nil{
                make.top.equalTo(imgView!.snp.bottom).offset(10)
            }else{
                make.top.equalTo(titleLab.snp.bottom).offset(10)
            }
            make.height.equalTo(30)
        
        }
        
    }
    func addTheImageView() -> Void {
        
    }
    func setCollectInfo(model : CollectModel) -> Void {
        for i in 0..<3{
            if let imgView = contentView.viewWithTag(201 + i){
                imgView.isHidden = true
            }
        }
        if let images = model.images{
            for i in 0..<images.count{
                let model = images[i]
                if let imgView = contentView.viewWithTag(201 + i) as? UIImageView{
                    imgView.isHidden = false
                    if let imgUrl = model.url{
                        imgView.kf.setImage(with: URL(string: imgUrl))
                    }
                }
                
            }
        }
       titleLab.text = model.title
    }

}
